# 单词逆序
# 声明s是个字符串
def reverseWords(s: str):
    # 返回一个列表
    tmp = s.split(' ')
    tmp.reverse()
    # 以空格作为分隔符产生新的字符串
    return ' '.join(tmp)


# print(reverseWords("Hello the World."))

# 旋转字符串
def rotateString(s: str, goal: str):
    if len(s) != len(goal):
        return False
    return goal in (s + s)


# print(rotateString("abcde", "deabc"))
# print(rotateString("abcde", "edacb"))

# 统计字符串前缀
def countPrefixes(words: list, s: str):
    count = 0
    for word in words:
        if s.startswith(word):
            count += 1
    return count


print(countPrefixes(['a', 'b', 'c', 'ab', 'bc', 'abc'], "abc"))
print(countPrefixes(['a', 'b', 'aa'], "ab"))

